package com.yxinsur.imc.business.enums;

import com.yxinsur.imc.common.utils.StringUtils;
import lombok.Getter;

/**
 * 计算周期类型  年  半年  季度  月
 */
@Getter
public enum PersistencyPeriodEnum {

    YEAR("年"),
    SEMESTER("半年"),
    QUARTER("季度"),
    MONTH("月");


    private String code;

    private PersistencyPeriodEnum(String code) {
        this.code = code;
    }

    public static String getCodeByPeriod(String method) {
        String keyValue = null;
        if (StringUtils.isNotBlank(method)) {
            for (PersistencyPeriodEnum c : PersistencyPeriodEnum.values()) {
                if (c.name().contains(method)) {
                    keyValue = c.getCode();
                    break;
                }
            }
        }
        return keyValue;
    }
}
